<template>
    <div class="index">
        <component :is="componentList[selected].nameA" :selected="componentList[selected].selected"></component>
        <div class="center">
            <ul>
                <li v-for="(item, index) in list" :key="index">
                    <div :class="[selected === index ? 'select' : '']" @click="selected = index">
                    <div :class="[selected === index ? 'select' : '']">
                        <img :src="selected === index ? item.img : item.selectImg" alt="" draggable="false">
                    </div>
                    </div>
                    <span :class="[selected === index ? 'select' : '']">{{item.name}}</span>
                </li>
            </ul>
        </div>
        <component :is="componentList[selected].nameB" :selected="componentList[selected].selected"></component>
    </div>
</template>

<script>
import ai from "../assets/img/ai.png"
import aiSelect from "../assets/img/aiSelect.png"
import monitor from "../assets/img/monitor.png"
import monitorSelect from "../assets/img/monitorSelect.png"
import care from "../assets/img/care.png"
import careSelect from "../assets/img/careSelect.png"
import module1 from "../components/module1.vue"
import module2 from "../components/module2.vue"
export default {
    name: "index",
    data() {
      return {
        list: [
            {name: "AI社区安全", img: ai, selectImg: aiSelect},
            {name: "高空抛物", img: monitor, selectImg: monitorSelect},
            {name: "独居老人关怀", img: care, selectImg: careSelect}
        ],
        selected: 0,
        componentList: [
            {nameA: "module1", nameB: "module2", selected: true}
        ]
      }
    },
    components: {
        module1,
        module2
    }
}
</script>

<style scoped>
.index {
    width: 100%;
    height: 100%;
    display: flex;
}
.index .center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.index .center ul {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 30px 0;
  display: flex;
  justify-content: space-around;
}
.index .center ul li {
  display: flex;
  flex-direction: column;
}

.index .center ul li span {
  position: relative;
}
.index .center ul li >div {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  margin-bottom: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: .3s;
}
.index .center ul li >div.select {
  border: 2px dashed #74EEFE;
  animation-name: spin;
  animation-duration: 0.3s;
  animation-timing-function: ease-in;
  animation-iteration-count: 1;
}
.index .center ul li >div>div {
  width: 84px;
  height: 84px;
  background-color: #E6E6E6;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: .3s;
}
.index .center ul li >div>div.select {
  border: 4px solid #74EEFE;
  background: rgba(0, 0, 0, 0.6);
}
.index .center ul li >div div img {
  height: 50px;
}
.index .center ul li span.select::after {
  content:"";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #038EE9;
  filter: blur(4px);
  z-index: -1;
}
</style>